import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'app_color_scheme.dart';

class AppTheme {
  static String defaultFont = 'Alibaba PuHuiTi 2.0';
  static String akFont = 'AkzidenzGroteskPro';
  static String btFont = 'EngraversGothicBT';

  static ThemeData light = getTheme(AppColorScheme.light);

  static ThemeData dark = getTheme(AppColorScheme.dark);

  static double cornerLarge = 20;
  static double cornerMedium = 16;
  static double cornerSmall = 10;
  static double cornerXSmall = 8;
  static double cornerFull = 100;

  static ThemeData getTheme(ColorScheme colorScheme) {
    TextTheme textTheme = TextTheme(
      displayMedium: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 24.sp,
        fontWeight: FontWeight.w500,
        height: 1.35,
        color: colorScheme.primary,
      ),
      headlineSmall: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 16.sp,
        fontWeight: FontWeight.w500,
        height: 1.5,
        color: colorScheme.onPrimary,
      ),
      headlineMedium: TextStyle(
        // fontFamily: defaultFont,
        //  fontFamilyFallback: ['sans-serif'],
        fontSize: 18.sp,
        fontWeight: FontWeight.w500,
        height: 1.45,
        color: colorScheme.onPrimary,
      ),
      titleSmall: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 14.sp,
        fontWeight: FontWeight.w500,
        height: 1.6,
        color: colorScheme.primary,
      ),
      titleMedium: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 16.sp,
        fontWeight: FontWeight.w500,
        height: 1.5,
        color: colorScheme.primary,
      ),
      titleLarge: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 18.sp,
        fontWeight: FontWeight.w500,
        height: 1.45,
        color: colorScheme.onPrimary,
      ),
      bodySmall: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 14.sp,
        fontWeight: FontWeight.w400,
        height: 1.6,
        color: colorScheme.onPrimary,
      ),
      bodyMedium: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 14.sp,
        fontWeight: FontWeight.w500,
        height: 1.6,
        color: colorScheme.onPrimary,
      ),
      labelSmall: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 12.sp,
        fontWeight: FontWeight.w400,
        height: 1.5,
        color: colorScheme.tertiary,
      ),
      labelMedium: TextStyle(
        // fontFamily: defaultFont,
        // fontFamilyFallback: ['sans-serif'],
        fontSize: 14.sp,
        fontWeight: FontWeight.w500,
        height: 1.6,
        color: colorScheme.tertiary,
      ),
    );
    return ThemeData(
      brightness: colorScheme.brightness,
      // fontFamily: defaultFont,
      // fontFamilyFallback: ['sans-serif', 'serif'],  // 优先sans-serif，其次serif
      colorScheme: colorScheme,
      iconButtonTheme: IconButtonThemeData(
        style: IconButton.styleFrom(
          foregroundColor: colorScheme.primary,
          padding: EdgeInsets.zero,
        ),
      ),
      elevatedButtonTheme: ElevatedButtonThemeData(
        style: ElevatedButton.styleFrom(
          elevation: 0,
          foregroundColor: colorScheme.primary,
          backgroundColor: colorScheme.secondaryContainer,
          disabledForegroundColor: colorScheme.secondary,
          disabledBackgroundColor: colorScheme.secondaryContainer,
          textStyle: textTheme.titleSmall,
          shadowColor: Colors.transparent,
        ),
      ),
      filledButtonTheme: FilledButtonThemeData(
        style: FilledButton.styleFrom(
          foregroundColor: colorScheme.primaryContainer,
          backgroundColor: colorScheme.primary,
          disabledForegroundColor: colorScheme.secondary,
          disabledBackgroundColor: colorScheme.tertiaryContainer,
        ),
      ),
      textButtonTheme: TextButtonThemeData(
        style: TextButton.styleFrom(
          foregroundColor: colorScheme.primaryFixed,
          textStyle: textTheme.titleSmall,
        ),
      ),
      textTheme: textTheme,
      bottomNavigationBarTheme: BottomNavigationBarThemeData(
        backgroundColor: colorScheme.secondaryContainer,
        elevation: 0,
        selectedItemColor: colorScheme.onPrimaryContainer,
        unselectedItemColor: colorScheme.onTertiary,
        unselectedLabelStyle: textTheme.labelSmall?.copyWith(
          color: colorScheme.onTertiary,
        ),
        selectedLabelStyle: textTheme.labelSmall?.copyWith(
          color: colorScheme.onPrimaryContainer,
        ),
        type: BottomNavigationBarType.fixed,
        enableFeedback: false,
      ),
    );
  }
}
